﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 渐变.admin_Form
{
    public partial class admin_comFrm : Form
    {
        /// <summary>
        /// 设置窗体的Region
        /// </summary>
        public void SetWindowRegion()
        {
            GraphicsPath FormPath;
            Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);
            FormPath = GetRoundedRectPath(rect, 50);
            this.Region = new Region(FormPath);

        }
        /// <summary>
        /// 绘制圆角路径
        /// </summary>
        /// <param name="rect"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        private GraphicsPath GetRoundedRectPath(Rectangle rect, int radius)
        {
            int diameter = radius;
            Rectangle arcRect = new Rectangle(rect.Location, new Size(diameter, diameter));
            GraphicsPath path = new GraphicsPath();

            // 左上角
            path.AddArc(arcRect, 180, 90);

            // 右上角
            arcRect.X = rect.Right - diameter;
            path.AddArc(arcRect, 270, 90);

            // 右下角
            arcRect.Y = rect.Bottom - diameter;
            path.AddArc(arcRect, 0, 90);

            // 左下角
            arcRect.X = rect.Left;
            path.AddArc(arcRect, 90, 90);
            path.CloseFigure();//闭合曲线
            return path;
        }
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case 0x84:
                    base.WndProc(ref m);
                    if ((int)m.Result == 0x1)
                        m.Result = (IntPtr)0x2;
                    return;
            }

            base.WndProc(ref m);
        }
        public admin_comFrm()
        {
            
            InitializeComponent();
        }
        public string cid { get; set; }
        public string carproblem { get; set; }
        private void btnSumit_Click(object sender, EventArgs e)
        {
            string sql = "update complaint set isHandle=@isHandle,handlepeople=@handlepeople,handTime=@handTime,handMsg=@handMsg where cid=@cid";
            SqlParameter[] ps =
            {
                new SqlParameter("@isHandle","True"),
                new SqlParameter("@handlepeople","超级管理员"),
                new SqlParameter("@handTime",DateTime.Now),
                new SqlParameter("@handMsg",txtMsg.Text),
                new SqlParameter("@cid",this.cid)
            };
            int res = DBHelper.ExecuteNonQuery(sql, ps);
            if (res > 0)
            {
                this.ShowSuccessTip("处理成功！");
                this.DialogResult = DialogResult.OK;
                this.Close();
                
            }
            else
            {
                this.ShowErrorTip("提交失败");
            }
        }

        private void admin_comFrm_Load(object sender, EventArgs e)
        {
            SetWindowRegion();
            txtContent.Text = this.carproblem;
        }

        private void label2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
